Skip to content

Fix: tenure downloader reward set error #6234 #6276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 14, 2025

Conversation

kantai
Copy link
Contributor

@kantai kantai commented Jul 10, 2025

This PR refactors the reward cycle fetching logic in the tenure downloader and fixes the #6234 bug.

First -- I moved the downloader_block_height_to_reward_cycle method into a newly named (and commented) method thats a static method of the NakamotoDownloadStateMachine struct. The logic of that calculation is: given a block commit at burn height X, what is the latest possible reward cycle for a tenure the commit confirms?

I think that the only places we want to use this calculation are in WantedTenures request generation -- basically, given a sortition tip, what tenures could we download and confirm?

The bug in #6234 was caused by the fact that this calculation was also used for the reward set caching logic of the (unconfirmed) tenure downloader. This meant that for the first two tenures of a new reward cycle, the wrong reward sets would be used for download validation. The fix for this was to simply use the normal reward set calculation in those instances.

This PR adds an integration test for this behavior: basically, perform signer-set rollover with 2 active nodes. Importantly, in order for the test to actually cover the behavior, the nodes need to refuse block pushes (otherwise, they never need to use the TenureDownloader at all).

@kantai kantai requested review from a team as code owners July 10, 2025 15:36
obycode
obycode previously approved these changes Jul 10, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the clear comments!

obycode
obycode previously approved these changes Jul 10, 2025
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

obycode
obycode previously approved these changes Jul 11, 2025
@kantai kantai added this to the 3.1.0.0.14 milestone Jul 11, 2025
@kantai kantai self-assigned this Jul 11, 2025
@kantai kantai moved this to Status: In Review in Stacks Core Eng Jul 11, 2025
@aldur aldur requested a review from Jiloc July 11, 2025 16:09
Jiloc
Jiloc previously approved these changes Jul 11, 2025
Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! The comment made it way clearer :) I just left a couple of comments that you can feel free to just close them and merge

Co-authored-by: Francesco <2530388+Jiloc@users.noreply.github.com>
@kantai kantai dismissed stale reviews from Jiloc and obycode via fde56b4 July 11, 2025 19:25
@kantai kantai requested a review from Jiloc July 11, 2025 20:49
Copy link
Contributor

@Jiloc Jiloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-project-automation github-project-automation bot moved this from Status: In Review to Status: 💻 In Progress in Stacks Core Eng Jul 11, 2025
@kantai kantai added this pull request to the merge queue Jul 14, 2025
@kantai kantai closed this Jul 14, 2025
Merged via the queue into stacks-network:develop with commit fbb3ae6 Jul 14, 2025
240 of 241 checks passed
@github-project-automation github-project-automation bot moved this from Status: 💻 In Progress to Status: ✅ Done in Stacks Core Eng Jul 14, 2025
@kantai kantai deleted the fix/tenure-downloader branch July 14, 2025 15:32
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

Attention: Patch coverage is 14.12214% with 225 lines in your changes missing coverage. Please review.

Project coverage is 77.96%. Comparing base (381ee9b) to head (fde56b4).
Report is 33 commits behind head on develop.

Files with missing lines Patch % Lines
stacks-node/src/tests/signer/v0.rs 4.32% 221 Missing ⚠️
...download/nakamoto/tenure_downloader_unconfirmed.rs 77.77% 4 Missing ⚠️

❌ Your project status has failed because the head coverage (77.96%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6276      +/-   ##
===========================================
- Coverage    82.10%   77.96%   -4.14%     
===========================================
  Files          546      546              
  Lines       347235   347462     +227     
  Branches       323      323              
===========================================
- Hits        285088   270897   -14191     
- Misses       62139    76557   +14418     
  Partials         8        8              
Files with missing lines Coverage Δ
...rc/net/download/nakamoto/download_state_machine.rs 86.51% <100.00%> (+0.06%) ⬆️
stackslib/src/net/download/nakamoto/mod.rs 89.36% <ø> (-1.38%) ⬇️
...download/nakamoto/tenure_downloader_unconfirmed.rs 72.19% <77.77%> (-0.25%) ⬇️
stacks-node/src/tests/signer/v0.rs 38.65% <4.32%> (-1.08%) ⬇️

... and 218 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 381ee9b...fde56b4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Invalid tenure-start block: bad signer signature, tenure_id: 4630b863aedb9ea92b92abf7ddea09fae014a0c1
3 participants